<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>发送验证码</button>
    <script>
        let btn = document.querySelector("button")
        btn.addEventListener("click", function () {
            let t = 60
            let timer = setInterval(function () {
                // 定义一个变量
                btn.disabled = true
                t--
                btn.innerHTML = `重新发送验证码(${t})`
                if (t < 1) {
                    btn.disabled = false
                    btn.innerHTML = `发送验证码`
                    clearInterval(timer)
                }
                console.log(t);

            }, 1000)

        })
    </script>
</body>

</html>